﻿using System.Data.SqlClient;
using System.Text;

namespace ExploreAndShare.Models.Daos
{
    public class GenericDao
    {
        private static SqlCommand GetCommand()
        {
            var sqlconn = new SqlConnection("");

            sqlconn.Open();

            return new SqlCommand
            {
                Connection = sqlconn,
                CommandType = System.Data.CommandType.Text
            };
        }

        public static void Save(StringBuilder query)
        {
            using (var command = GetCommand())
            {
                var tn = command.Connection.BeginTransaction();
                command.CommandText = query.ToString();
                command.Transaction = tn;
                command.ExecuteNonQuery();
                tn.Commit();
            }
        }
    }
}